<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataDt">
              <j-date placeholder="请输入数据日期" v-model="model.dataDt"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdm">
              <a-input v-model="model.jrjgdm" placeholder="请输入金融机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="债券代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zqdm">
              <a-input v-model="model.zqdm" placeholder="请输入债券代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="债券总托管机构" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zqztgjg">
              <a-input v-model="model.zqztgjg" placeholder="请输入债券总托管机构"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="债券品种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zqpz">
              <a-input v-model="model.zqpz" placeholder="请输入债券品种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="债券信用级别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zqxyjb">
              <a-input v-model="model.zqxyjb" placeholder="请输入债券信用级别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="续发次数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xfcs">
              <a-input-number v-model="model.xfcs" placeholder="请输入续发次数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
              <a-input v-model="model.bz" placeholder="请输入币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="期末债券面值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qmzqmz">
              <a-input-number v-model="model.qmzqmz" placeholder="请输入期末债券面值" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="期末债券面值折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qmzqmzzrmb">
              <a-input-number v-model="model.qmzqmzzrmb" placeholder="请输入期末债券面值折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="期末债券余额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qmzqye">
              <a-input-number v-model="model.qmzqye" placeholder="请输入期末债券余额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="期末债券余额折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qmzqyezrmb">
              <a-input-number v-model="model.qmzqyezrmb" placeholder="请输入期末债券余额折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="债权债务登记日" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zqzwdjr">
              <a-input v-model="model.zqzwdjr" placeholder="请输入债权债务登记日"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="起息日" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qxr">
              <a-input v-model="model.qxr" placeholder="请输入起息日"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="兑付日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dfrq">
              <a-input v-model="model.dfrq" placeholder="请输入兑付日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="付息方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fxfs">
              <a-input v-model="model.fxfs" placeholder="请输入付息方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票面利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pmll">
              <a-input-number v-model="model.pmll" placeholder="请输入票面利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectNo">
              <a-input v-model="model.subjectNo" placeholder="请输入科目代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectName">
              <a-input v-model="model.subjectName" placeholder="请输入科目名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khmc">
              <a-input v-model="model.khmc" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khdm">
              <a-input v-model="model.khdm" placeholder="请输入客户代码"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JsPStoIssInfForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/JsPStoIssInf/jsPStoIssInf/add",
          edit: "/JsPStoIssInf/jsPStoIssInf/edit",
          queryById: "/JsPStoIssInf/jsPStoIssInf/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
